home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / dialog / fcombom.c < prev    next >
C/C++ Source or Header  |  1995-12-15  |  1KB  |  67 lines

  1. #include <string.h>
  2. #include "dialog.h"
  3. #include "fcombo.h"
  4.  
  5. PUBLIC ELM_STR_V::ELM_STR_V(const char *_str, char &_selected)
  6.     : selected(_selected), ELM_STR(" ",_str)
  7. {
  8. }
  9.  
  10. /*
  11.     Setup a combo box where the user is allowed to pick several option
  12.     at once from the pick list (unlike FIELD_COMBO)
  13. */
  14. PUBLIC FIELD_COMBO_MANY::FIELD_COMBO_MANY(
  15.     const char *_prompt,
  16.     SSTRING &_str)
  17.     : FIELD_COMBO(_prompt,_str)
  18. {
  19. }
  20.  
  21. /*
  22.     Add one string option to the combo box pick list.
  23.     This time there is two string. The strings will be show in
  24.     the pick list like this
  25.  
  26.     value verbose
  27. */
  28. PUBLIC void FIELD_COMBO_MANY::addopt(
  29.     const char *str,
  30.     char &selected)
  31. {
  32.     opts->add (new ELM_STR_V(str,selected));
  33. }
  34.  
  35. PROTECTED void FIELD_COMBO_MANY::assist(WINDOW *dialog)
  36. {
  37.     int nbopt = opts->getnb();
  38.     DIALOG dia;
  39.     for (int i=0; i<nbopt; i++){
  40.         ELM_STR_V *elm = (ELM_STR_V*)opts->getitem(i);
  41.         dia.newf_chk ("",elm->selected,elm->verbose);
  42.     }
  43.     dia.edit ("Option list"
  44.         ,"Select active option"
  45.         ,NULL
  46.         ,0);
  47.     touchwin(stdscr);
  48.     touchwin(dialog);
  49. }
  50.  
  51. /*
  52.     Add a combo field to the dialog.
  53.     The object will be destroyed by the dialog itself.
  54.     The object is returned so the caller may add options in the
  55.     pick list.
  56. */
  57. PUBLIC FIELD_COMBO_MANY *DIALOG::newf_combo_many(
  58.     const char *prompt,
  59.     SSTRING &str)
  60. {
  61.     FIELD_COMBO_MANY *s = new FIELD_COMBO_MANY(prompt,str);
  62.     if (s != NULL) add (s);
  63.     return s;
  64. }
  65.  
  66.  
  67.